package behavioral.interpreter;

/**
 * @ClassName: AddExpression
 * @Description: 非终结符表达式：用于解释语言中的非终结符
 * @Author: liu-hao
 * @Date: 2023-04-12 10:26
 * @Version: 1.0
 **/
public class AddExpression implements Expression {

    private Expression leftExpression;
    private Expression rightExpression;

    public AddExpression(Expression leftExpression, Expression rightExpression) {
        this.leftExpression = leftExpression;
        this.rightExpression = rightExpression;
    }

    @Override
    public int interpret(Context context) {
        return leftExpression.interpret(context) + rightExpression.interpret(context);
    }
}
